package cheme.ProcessModel;

public class IdGenerator implements IIdGenerator
{
	private String base = "";
	private int suffix = 1;

	public IdGenerator(String base)
	{
		setBase(base);
	}
	
	public String createId()
	{
		String id = getSuffixString();
		incrementSuffix();
		return getBase() + id;
	}

	public void initialize(String base)
	{
		setBase(base);
		initializeSuffix();
	}
	
	public void initializeSuffix()
	{
		setSuffix(1);
	}
	
	protected String getSuffixString()
	{
		return Integer.toString(suffix);
	}
	
	protected void incrementSuffix()
	{
		setSuffix( getSuffix() + 1);
	}
	
	protected int getSuffix()
	{
		return suffix;
	}

	protected void setSuffix(int suffix)
	{
		this.suffix = suffix;
	}

	protected String getBase()
	{
		return base;
	}

	public void setBase(String base)
	{
		this.base = base;
	}

}
